/**
 * dataurl: base64
 * filename: 设置文件名称
*/
// export const dataURLtoFile = (dataurl, filename) => {
//   let arr = dataurl.split(','),
//   mime = arr[0].match(/:(.*?);/)[1],
//   bstr = atob(arr[1]),
//   n = bstr.length,
//   u8arr = new Uint8Array(n);
//   while (n--) {
//     u8arr[n] = bstr.charCodeAt(n);
//   }
//   return new File([u8arr], filename, {
//     type: mime
//   });
// }
export const dataURLtoFile = (dataURI) => {
  let binary = atob(dataURI.split(",")[1]);
  let array = [];
  for (let i = 0; i < binary.length; i++) {
    array.push(binary.charCodeAt(i));
  }
  return new Blob([new Uint8Array(array)], { type: "image/jpeg" });
}
